<?php
namespace app\middleware;

require_once('../extend/JWT.php');

class JWTAUTH
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        //return '1111';
        if(null == $request->header('Authorization')){
          return redirect('noright/relogin');
        }
        //var_dump($request->header('Authorization'));die;
        $jwt_header=$request->header('Authorization');
        $jwtObj= new JWT('');
        if($jwtObj->check($jwt_header)){
            return $next($request);
        }else{
            return redirect('noright/retoken');
        }
    }

    public function end(\think\Response $response){

    }
}
